<template>
  <div class="newreply">
    <!-- 标题 -->
    <h3 class="iconfont">&#xe665; 最新回复</h3>
    <!-- 消息 -->
    <ul>
      <li v-for="item in newComment" :key="item.id">
        <span class="uname">{{ item.nickname }}</span>
        <span class="date">{{ this.shiftDate(item.createDate) }}123</span>
        <div class="content">
          <span></span>
          <p>感谢分享，赞一个！</p>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
  //  导入时间 库
  import * as dayjs from 'dayjs';
  import { newestArticleComment } from '../../api/articlei.js';
  export default {
    name: 'NewReply',
    data() {
      return {
        newComment: [],
      };
    },
    methods: {
      async getNewComment() {
        const { data: res } = await newestArticleComment();
        if (res) {
          this.newComment = res.data;
          console.log(this.newComment);
        }
      },
      //  转换日期格式
      shiftDate(date) {
        dayjs(date).format('YYYY-MM-DD');
      },
    },

    created() {
      this.getNewComment();
    },
  };
</script>

<style lang="less" scoped>
  @import url('../../state/css/register/newreply.less');
</style>
